# 作者：陈睿-cruise
# 2025年02月10日21时37分30秒
# 2979386061@qq.com
class Furniture:
    """家具类"""
    def __init__(self, name, area):
        self.name = name
        self.area = area

    def __str__(self):
        return f"{self.name}（占地 {self.area} 平米）"


class House:
    """房屋类"""
    def __init__(self, address, total_area):
        self.address = address  # 地址
        self.total_area = total_area  # 总面积
        self.remaining_area = total_area  # 剩余面积
        self.furniture_list = []  # 已有家具列表

    def add_furniture(self, furniture):
        """添加家具"""
        if furniture.area > self.remaining_area:
            print(f"❌ 无法添加 {furniture.name}，剩余面积不足！")
        else:
            self.furniture_list.append(furniture)
            self.remaining_area -= furniture.area
            print(f"✅ {furniture.name} 添加成功！剩余面积：{self.remaining_area} 平米")

    def show_furniture(self):
        """显示房屋内的家具"""
        print(f"\n🏠 房屋地址：{self.address}，总面积：{self.total_area} 平米，剩余面积：{self.remaining_area} 平米")
        print("📌 已有家具：" + ", ".join(str(f) for f in self.furniture_list) if self.furniture_list else "无")

    def remove_furniture(self, furniture_name):
        """删除家具"""
        for furniture in self.furniture_list:
            if furniture.name == furniture_name:
                self.furniture_list.remove(furniture)
                self.remaining_area += furniture.area
                print(f"✅ {furniture_name} 已移除！剩余面积：{self.remaining_area} 平米")
                return
        print(f"❌ 房屋中没有找到 {furniture_name}！")


# 测试代码
bed = Furniture("床", 4)
sofa = Furniture("沙发", 3)
table = Furniture("餐桌", 2)

my_house = House("北京市 朝阳区", 10)

my_house.add_furniture(bed)
my_house.add_furniture(sofa)
my_house.add_furniture(table)
my_house.show_furniture()

my_house.remove_furniture("沙发")
my_house.show_furniture()

my_house.add_furniture(Furniture("衣柜", 5))  # 测试超出剩余面积
